<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/ajax2.js"></script>
</head>

<body>
    <button>发送请求</button>

    <script>
        const btnObj = document.querySelector("button")
        /* 
        服务端没有解决跨域访问
        就是没有打开如下的头部信息
       Access-Control-Allow-Origin": "*"

        
        */
        btnObj.onclick = function () {
            ajax({
                url: 'http://www.biwuit.cn/spboot/cross2',
                success: function (data) {
                    console.log("访问成功")
                    console.log(data)
                }
            })
        }
    </script>
</body>

</html>